<!-- 悬赏 -->
<template>
	<div class="main">
		<!-- 标题 -->
		<div class="title flex flex-y flex-between">
			<h3>{{title}}</h3>
			<div class="right">
				<el-button
					v-loading="loading"
					@click="save()"
					class="right"
					type="primary"
					size="small">保存
				</el-button>
				<el-button class="right" size="small" @click="ifShow = true">变动日志</el-button>
			</div>
		</div>
		<!-- 内容 -->
		<div class="content">
			<div class="area">
				<h3 class="title">悬赏默认值</h3>
				<div class="flex flex-y group">
					<p>悬赏默认值</p>
					<ipt v-model="formData.reward[0].paramValue" style="width:50px" class="left10"/>
					<ipt v-model="formData.reward[1].paramValue" style="width:50px" class="left10"/>
					<ipt v-model="formData.reward[2].paramValue" style="width:50px" class="left10"/>
					<ipt v-model="formData.reward[3].paramValue" style="width:50px" class="left10"/>
				</div>
			</div>
			<div class="area">
				<h3 class="title">作者收益设置</h3>
				<div class="flex flex-y group">
					<div class="flex flex-y">
						<p>平台抽成</p>
						<ipt v-model="formData.rewardIncome[0].paramValue" style="width:50px" class="left10 right10"/>
						<p class="right60">%</p>
					</div>
					<div class="flex flex-y">
						<p>税率</p>
						<ipt v-model="formData.rewardIncome[1].paramValue" style="width:50px" class="left10 right10"/>
						<p>%</p>
					</div>
				</div>
			</div>
		</div>
		<!-- 变动日志 -->
		<el-dialog title="变动日志" :visible.sync="ifShow">
			<airlog query="reward" />
		</el-dialog>
	</div>
</template>

<script>
import log from '@/components/finance/set/log.vue'
import airlog from '@/pages/runManage/param/components/log.vue'
export default {
	props:["title","data"],
	components:{
		log,
		airlog
	},
	data () {
		return {
			loading:false,
			ifShow:false,
			//////
			submitData:[], //处理后的数据，提交给后端的
			formData:{
				reward:[
					{
						paramValue:0
					},
					{
						paramValue:0
					},
					{
						paramValue:0
					},
					{
						paramValue:0
					}
				],
				rewardIncome:[
					{
						paramValue:0
					},
					{
						paramValue:0
					},
				]
			},
		}
	},
	watch:{
		// 默认值
		data(val){
			this.formData = val;
		},
	},
	methods:{
		save:function(){
			this.loading = true;
			// 拼接字段
			this.opData();
			// 请求
			HTTP('financeSet_save', this.submitData)
			.then(res=>{
				this.loading = false;
				if(res.code == 200){
					this.common.msg('保存成功');
				}
				else{
					this.common.msg(res.msg,'error');
				}
			})
		},
		//处理数据
		opData:function(){
			// 悬赏默认值
			this.formData.reward.map(o=>{
				this.submitData.push({
					uid:o.uid,
					paramType:o.paramType,
					paramName:o.paramName,
					paramValue:o.paramValue,
				});
			})
			// 作者收益
			this.formData.rewardIncome.map(o=>{
				this.submitData.push({
					uid:o.uid,
					paramType:o.paramType,
					paramName:o.paramName,
					paramValue:o.paramValue,
				});
			})
		},
	},
	mounted(){

	}
}
</script>

<style lang="scss" scoped>
	/deep/ .el-input__inner{
		text-align: center;
		height: 33px;
		line-height: 33px;
	}
	.main{
		padding: 25px 30px;
		//标题
		.title{
			position: relative;
			h3{
				font-size: 16px;
			}
			h3:before{
				position: absolute;
				left: -16px;
				top: 5px;
				content:'\25CF';
				color: $blue;
			}
		}
	}
	.content{
		//margin-top: 40px;
		.area{
			.title{
				padding: 44px 0 4px 0;
				font-size: 16px;
				color: $blue;
			}
			.group{
				label{
					display: block;
					width: 66px;
					text-align: left;
				}
				margin: 14px 0;
			}
			.right60{
				margin-right: 60px;
			}
		}
	}
</style>
